package chap06;



import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Tools {
    //平均分
    public static double getAvg(List<Student> stuList){
        //所有成绩的和
        double sum=0;
        for (Student s : stuList) {
            sum=sum+s.getScore();
        }
        return sum/stuList.size();

    }
    //获得不及格学生
    public static List<Student> getScore(List<Student> list){
        List<Student> stus=new ArrayList<>();//把不及格的学生放到stus集合中
        Iterator<Student> it=list.iterator();
        while(it.hasNext()){
            Student stu=it.next();
            if(stu.getScore()<60){
                stus.add(stu);
            }
        }
        return stus;



    }
}

